import log from '@dfeidao/atom-nodejs/logger/log';
import { IncomingHttpHeaders } from 'http';
import complex_query from '@dfeidao/atom-nodejs/db/complex-query';
import { systemid } from '../../atom/config';

interface Message {
filter:{
	project_no:string,
	content:string,
	source_type:string,
	work_order_status:string
	startime:string,
	endtime:string
}
}


export default async function atom(message: Message, action_id: string, session_id: string, headers: IncomingHttpHeaders){
	const query = complex_query(action_id,session_id,systemid);
const res = await query
 
// 添加字段
	.add_field('work_order', 'work_bill_no', 'work_bill_no')
	.add_field('work_order', 'job_content', 'job_content')
	.add_field('work_order', 'cust_name', 'cust_name')
	.add_field('work_order', 'project_no', 'project_no')
	.add_field('work_order', 'project_name', 'project_name')
	.add_field('work_order', 'create_time', 'create_time')
	.add_field('work_order', 'work_order_status', 'work_order_status')
	.add_field('work_order', 'source_type', 'source_type')
    .where_like('work_order', 'project_no', '%'+message.filter.project_no+'%')
    .where_like('work_order', 'job_content', '%'+message.filter.content+'%')
    .where_like('work_order', 'source_type', '%'+message.filter.source_type+'%')
    .where_like('work_order', 'work_order_status','%'+message.filter.work_order_status+'%')
    //大于
    .where_gt('work_order', 'create_time',message.filter.startime)
    // 小于
    .where_lt('work_order', 'create_time', message.filter.endtime)
    //结束
	.exec();
	return {res};
}
